require 'rake/clean'

DOT_NET_PATH = "#{ENV["SystemRoot"]}\\Microsoft.NET\\Framework\\v3.5"
NUNIT_EXE = "tools/Nunit/nunit-console.exe"
OUTPUT_PATH = "output"
CONFIG = "Debug"
 
CLEAN.include(OUTPUT_PATH)
directory "#{OUTPUT_PATH}/test"

task :default => :build
task :build => [:clean, :compile, :test, :deploy] 

task :compile do  
  sh "#{DOT_NET_PATH}/msbuild.exe /t:Rebuild /nologo /v:m /p:Configuration=#{CONFIG} yatfram.sln"
end

task :test => [:copy_internet_explorer_driver, "#{OUTPUT_PATH}/test"] do 
  testdll = "Yatfram.Tests/bin/#{CONFIG}/Yatfram.Tests.dll"  
  outputfile = "#{OUTPUT_PATH}/test/testresults.xml"
  sh "#{NUNIT_EXE} #{testdll} /xml=#{outputfile}"
end

task :deploy do
  sh "echo deploy task not yet implemented!"
end

task :copy_internet_explorer_driver do
  architecture_dir = if ENV["PROCESSOR_ARCHITECTURE"] == "x86" then "Win32" else "x64" end
  cp "3rdParty/selenium-dotnet-2.0a1/#{architecture_dir}/InternetExplorerDriver.dll", "Yatfram.Tests/bin/#{CONFIG}"
end
